home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / msdos / chgpal / palette.asm < prev   
Assembly Source File  |  1991-10-18  |  3KB  |  117 lines

  1.     .286c
  2.     page    ,132
  3. ;***********************************************************************
  4. ;*                                                                     *
  5. ;*  TOWNSのテキスト用パレット色変更                               *
  6. ;*                                                                     *
  7. ;*  [呼出] call chg_pal( mode , color , n_red , n_green , n_blue ) ;   *
  8. ;*  [入力] mode    : 処理モード( 0 : 割合読出 , 1 : 割合書出 )         *
  9. ;*         color   : 変更する色番号(1~7,8~15)                        *
  10. ;*         n_red   : 赤色の割合数  (0~15)                             *
  11. ;*         n_green : 緑色の割合数  (0~15)                             *
  12. ;*         n_blue  : 青色の割合数  (0~15)                             *
  13. ;*  [出力] n_red   : 赤色の割合数  (0~15)                             *
  14. ;*         n_green : 緑色の割合数  (0~15)                             *
  15. ;*         n_blue  : 青色の割合数  (0~15)                             *
  16. ;*                                                                     *
  17. ;*---------------------------------------------------------------------*
  18. ;*   1 : 1991/06/19 Created by M.Watari                                *
  19. ;*                                                                     *
  20. ;***********************************************************************
  21.     public    _chg_pal
  22. _TEXT    segment    word public 'CODE'
  23.     assume    cs:_TEXT
  24. ;
  25. VD_ADRS        EQU     0448h    ; ビデオ出力コントローラ
  26. VD_DATA        EQU     044ah    ; ビデオ出力I/Oレジスタ
  27. PL_CODE        EQU    0fd90h    ; アナログパレットアドレス
  28. PL_BLUE        EQU    0fd92h    ; 青色のパレットアドレス
  29. PL_RED        EQU    0fd94h    ; 赤色のパレットアドレス
  30. PL_GREEN    EQU    0fd96h    ; 緑色のパレットアドレス
  31. ;
  32. ;  メインルーチン
  33. ;
  34. _chg_pal    proc    near
  35. mode    equ    ss:[bp+4]
  36. color    equ    ss:[bp+6]
  37. n_red    equ    ss:[bp+8]
  38. n_green    equ    ss:[bp+10]
  39. n_blue    equ    ss:[bp+12]
  40.     enter    0,0
  41.     push    ax
  42.     push    bx
  43.     push    dx
  44.     push    di
  45.  
  46.     mov    dx,VD_ADRS    ; テキスト用パレットを書き込み対象にする
  47.     mov    al,01h        ; プライオリティレジスタに設定(01)
  48.     out    dx,al        ;
  49.     mov    dx,VD_DATA    ;
  50.     mov    al,021h        ; レイア1用16色パレットに設定(PLT0:1,PLT1:0)
  51.     out    dx,al
  52. ;            指定された色番号のパレットの設定
  53.     mov    ax,color    ; 色番号の設定
  54.     mov    dx,PL_CODE
  55.     out    dx,al
  56.  
  57.     mov    bx,mode
  58.     cmp    bx,0
  59.     jne    short Set_clr
  60. Get_clr:
  61. ;            青色用パレット値の取り出し
  62.     xor    ax,ax
  63.     mov    dx,PL_BLUE
  64.     in    al,dx
  65.     mov    di,n_blue
  66.     shr    al,4
  67.     mov    [di],ax        ; 青色用パレット値の設定
  68. ;            赤色用パレット値の取り出し
  69.     xor    ax,ax
  70.     mov    dx,PL_RED
  71.     in    al,dx
  72.     mov    di,n_red
  73.     shr    al,4
  74.     mov    [di],ax        ; 赤色用パレット値の設定
  75. ;            緑色用パレット値の取り出し
  76.     xor    ax,ax
  77.     mov    dx,PL_GREEN
  78.     in    al,dx
  79.     mov    di,n_green
  80.     shr    al,4
  81.     mov    [di],ax        ; 緑色用パレット値の設定
  82.     jmp    short finish    ; 指定色番号の各色の状態値取り出し終了
  83.  
  84. Set_clr:
  85. ;            青色用パレット値の設定
  86.     mov    dx,PL_BLUE
  87.     mov    ax,n_blue
  88.     shl    ax,4
  89.     out    dx,al
  90. ;            赤色用パレット値の設定
  91.     mov    dx,PL_RED
  92.     mov    ax,n_red
  93.     shl    ax,4
  94.     out    dx,al
  95. ;            緑色用パレット値の設定
  96.     mov    dx,PL_GREEN
  97.     mov    ax,n_green
  98.     shl    ax,4
  99.     out    dx,al
  100.  
  101. finish:
  102.     mov    dx,VD_ADRS    ; テキスト用パレットを元に戻す
  103.     mov    ax,01h        ; プライオリティレジスタに設定(01)
  104.     out    dx,ax        ;
  105.     mov    dx,VD_DATA    ;
  106.     out    dx,ax        ; レイア0用16色パレットに設定(PLT0:0,PLT1:0)
  107.  
  108.     pop    di
  109.     pop    dx
  110.     pop    bx
  111.     pop    ax
  112.     leave
  113.     ret
  114. _chg_pal    endp
  115. _TEXT    ends
  116.     end
  117.